package com.hkctp.mybatis.service;

import com.hkctp.mybatis.domain.User;
import com.hkctp.mybatis.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserService {

    @Autowired
    public UserMapper userMapper;

    public List<User> likeName(String name){
        return userMapper.likeName(name);
    }

    @Transactional      //添加事务
    public void save(User user){
        userMapper.save(user);
    }

    @Transactional      //添加事务
    public void updateUser(User user){
        userMapper.updateUser(user);
    }

    @Transactional      //添加事务
    public void deleteUser(User user){
        userMapper.deleteUser(user);
    }
}
